package com.ricervcvcer.brand.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

import java.util.ArrayList;

@Configuration //配置类
@EnableSwagger2// 开启Swagger2的自动配置
public class SwaggerConfig {
    //文档作者信息
    public static final Contact DEFAULT_CONTACT = new Contact("moge", "http://127.0.0.1:8080", "xxxx@xx.com");

    //获得接口API文档信息
    private ApiInfo apiInfo() {

        return new ApiInfo(
                "ricervcvcer API Document",
                "ricervcvcer接口 Swagger2 API 文档",
                "1.0",
                "http://127.0.0.1:8080",
                DEFAULT_CONTACT,
                "Apache 2.0",
                "http://www.apache.org/licenses/LICENSE-2.0",
                new ArrayList());
    }

    @Bean
    public Docket docket() {
        return
                new Docket(DocumentationType.SWAGGER_2)
                        .apiInfo(apiInfo())
                        .select().apis(RequestHandlerSelectors.basePackage("com.ricervcvcer.brand.controller")).build();
    }
}